package com.shuoyue.adven.service;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.util.Log;

import androidx.annotation.Nullable;

import com.shuoyue.adven.entity.Adv;
import com.shuoyue.adven.event.AddBusinessAdvEvent;
import com.sm.appbase.net.exception.NetErrorException;

import org.greenrobot.eventbus.EventBus;

import java.util.ArrayList;
import java.util.List;

import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.disposables.Disposable;

public class NetWorkService extends Service implements NetWorkServiceContract.View {
    protected CompositeDisposable mCompositeDisposable;

    @Nullable
    @Override
    public IBinder onBind(Intent intent) {
        return null;
    }


    @Override
    public void onDestroy() {
        if (mCompositeDisposable != null) {
            mCompositeDisposable.clear(); // clear时网络请求会随即cancel
            mCompositeDisposable = null;
        }
        Log.e("act", "destroy");
        super.onDestroy();
    }


    @Override
    public void bindDispos(Disposable disposable) {
        if (mCompositeDisposable == null || mCompositeDisposable.isDisposed()) {
            mCompositeDisposable = new CompositeDisposable();
        }
        mCompositeDisposable.add(disposable);
    }

    //<editor-folder desc="基类无需处理的实现">

    @Override
    public void showLoading() {
    }

    @Override
    public void showLoading(String title) {
    }

    @Override
    public void hideLoading() {
    }

    @Override
    public void onError(NetErrorException throwable) {
    }

    @Override
    public void toast(String msg) {
    }
//<editor-folder>

}
